package com.example.shopping.mapper;

import com.example.shopping.entity.Goods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface GoodsMapper {
    //查找所有商品
    List<Goods> selectAll();
    //查询所有最新商品
    List<Goods> selectAllNew();

    // 新增分页相关方法
    List<Goods> selectPage(@Param("offset") int offset, @Param("pageSize") int pageSize,@Param("searchName")String searchName,@Param("categoryId")Integer categoryId);


    long count(@Param("searchName")String searchName);


    List<Goods> selectAllHot();

    Goods findById(int id);


    Integer countByCategoryId(int categoryId);

    int insertGood(Goods good);

    void reduceStock(Integer goodid, Integer num);
}